package net.hn.hnms.biz.safety.trinity.group.controller;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import net.hn.hnms.biz.safety.trinity.group.domain.dto.RiskListDto;
import net.hn.hnms.biz.safety.trinity.group.domain.vo.RiskLevelVO;
import net.hn.hnms.biz.safety.trinity.group.domain.vo.RiskListVo;
import net.hn.hnms.biz.safety.trinity.group.domain.vo.RiskManagementVo;
import net.hn.hnms.biz.safety.trinity.group.domain.vo.RisklevelSumByCompanyVo;
import net.hn.hnms.biz.safety.trinity.group.service.RiskRecordGroupService;
import net.hn.hnms.sys.common.core.domain.R;
import net.hn.hnms.sys.common.core.domain.ResponsePage;
import net.hn.hnms.sys.common.mybatis.core.page.PageQuery;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

@RestController
@RequestMapping("group/manage/riskRecord")
@Api(value = "集团端安全风险控制器", tags = {"集团端安全风险"})
public class RiskRecordGroupControlle {

    @Resource
    private RiskRecordGroupService recordGroupService;

    /**
     * 风险列表分页查询
     * @param pageQuery
     * @param riskListDto
     * @return
     */
    @GetMapping("riskList/pageList")
    @ApiOperation("风险列表分页查询")
    public R<ResponsePage<RiskListVo>> riskListPageList(PageQuery pageQuery, RiskListDto riskListDto) {
        ResponsePage<RiskListVo> page=recordGroupService.riskListPageList(pageQuery, riskListDto);
        return R.ok(page);
    }

    /**
     * 按风险等级统计风险数量-饼图
     */
    @GetMapping("riskCountByRiskLevel")
    @ApiOperation("按风险等级统计风险数量-饼图")
    public R<RiskLevelVO> riskCountByRiskLevel(@ApiParam(value = "公司编码，默认不传查询所有公司") String companyCode,
                                               @ApiParam(value = "煤矿编码") String mineCode) {

        RiskLevelVO riskLevelVO = recordGroupService.riskCountByRiskLevel(companyCode, mineCode);
        return R.ok(riskLevelVO);
    }

    /**
     * 按风险等级统计风险数量-饼图
     */
    @GetMapping("riskCountByRiskLevelByCompanyCode")
    @ApiOperation("按风险等级统计风险数量-柱状图")
    public R<List<RisklevelSumByCompanyVo>> riskCountByRiskLevelByCompanyCode(@ApiParam(value = "公司编码，默认不传查询所有公司") String companyCode) {

        List<RisklevelSumByCompanyVo> voList = recordGroupService.riskCountByRiskLevelByCompanyCode(companyCode);
        return R.ok(voList);
    }
    /**
     * 双重预防-风险管控
     */
    @GetMapping("riskManagement")
    @ApiOperation("双重预防-风险管控index")
    public R<RiskManagementVo> riskManagement(@ApiParam(value = "公司编码，默认不传查询所有公司") String companyCode,
                                              @ApiParam(value = "煤矿编码，默认不传查询所有公司") String mineCode) {

        RiskManagementVo  riskManagementVo = recordGroupService.riskManagement(companyCode,mineCode);
        return R.ok(riskManagementVo);
    }
}
